package chpt08;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class SerializationTest {

	public static void main(String[] args) throws IOException,ClassNotFoundException{
		String filename = "person.dat";
		try(ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(filename))){
			Person p = new Person(1,"张三","123456");
			out.writeObject(p);
		}
		try(ObjectInputStream in = new ObjectInputStream(new FileInputStream(filename))){
			Person p = (Person)in.readObject();
			System.out.println(p);
		}
	}
}
